import wordcloud as wc
import matplotlib.pylab as plb
import jieba
from PIL import Image
from numpy import array
path="e:/老九门.txt"
data=open(path,"r",encoding="gbk").read()
cutdata=jieba.cut(data)
alldata=""
for i in cutdata:
    alldata=alldata+" "+str(i)
font=r"C:\Windows\Fonts\simhei.ttf"
cat=Image.open("e:/cat.png")
catarray=array(cat)
mywc=wc.WordCloud(collocations=False,font_path=font,mask=catarray,background_color="white").generate(alldata)
plb.imshow(mywc)
plb.show()
